import level1 from './main/level1'
import level2 from './main/level2'
import level3 from './main/level3'
import level4 from './main/level4'
import level5 from './main/level5'
import level6 from './main/level6'
import level7 from './main/level7'
import level8 from './main/level8'
import level9 from './main/level9'
import level10 from './main/level10'
import level11 from './main/level11'
import level12 from './main/level12'
import level13 from './main/level13'
import level14 from './main/level14'
import level15 from './main/level15'
import level16 from './main/level16'
import level17 from './main/level17'
import level18 from './main/level18'
import level19 from './main/level19'
import level20 from './main/level20'
import level21 from './main/level21'
import level22 from './main/level22'
import level23 from './main/level23'
import level24 from './main/level24'
import level25 from './main/level25'
import level26 from './main/level26'
import level27 from './main/level27'
import level28 from './main/level28'
import level29 from './main/level29'
import level30 from './main/level30'

// let level
import sql from './main/level31/createTable.sql?raw'

// 导入接口代码
import request from '../api'

let level = [] as LevelType[]
let levelList = []
// 获取所有关卡
await request.level
  .getAllLevel({ pageNum: 1, pageSize: 999999 })
  .then((res: any) => {
    levelList = res.data.list
    console.log('levelList===>', levelList)
    for (let i = 0; i < levelList.length; i++) {
      level[i] = {
        key: 'level' + i * 10,
        title: levelList[i].title,
        initSQL: sql,
        content:
          '# ' +
          levelList[i].title +
          '\n## 教程\n' +
          levelList[i].tutorial +
          '\n## 示例\n' +
          levelList[i].example +
          '\n## 题目\n' +
          levelList[i].topic,
        defaultSQL: 'select * from student',
        answer: levelList[i].rfanswer,
        hint: '请仔细查看本关给出的示例',
        type: levelList[i].typeName
      } as LevelType
    }
  })

/**
 * 主线关卡列表
 */
const mainLevels: LevelType[] = [
  ...level,
  level1,
  level2,
  level3,
  level4,
  level5,
  level6,
  level7,
  level8,
  level9,
  level10,
  level11,
  level12,
  level13,
  level14,
  level15,
  level16,
  level17,
  level18,
  level19,
  level20,
  level21,
  level22,
  level23,
  level24,
  level25,
  level26,
  level27,
  level28,
  level29,
  level30
]

export default mainLevels
